#!/bin/sh

TOMCAT_NAME='tomcat'

MONITER_NAME='monitorTomcat.sh'

time=`date +%F--%T`

remote_host=`ifconfig | grep inet | grep -v '10.134' | grep -v '127.0' |awk '{print $2}'`


echo '当前时间：'$time',启动服务器'$remote_host'上的 TOMCAT'


/szcg/apache-tomcat-7.0.69/bin/startup.sh

TOMCAT_PID=`ps -ef | grep "$TOMCAT_NAME" | grep -v "$0" | grep -v "grep" | grep -v "tail" | awk '{print $2}'`

echo 'tomcat 已启动，当前tomcat的进程PID为：'$TOMCAT_PID',等待5分钟之后启动监控程序monitorTomcat.sh'

sleep 300

rm -rf /szcg/tool/monitorTomcat.out

sleep 5

#/szcg/tool/start.sh

echo '启动监控，有日志输入之后，执行 ctrl+c 结束进程'

cd /szcg/tool/
./start.sh

MONITER_PID=`ps -ef | grep "$MONITER_NAME" | grep -v "$0" | grep -v "grep" | grep -v "tail" | awk '{print $2}'`

echo '监控已启动，PID='$MONITER_PID
  
